<template>
	<!-- 新增车辆 -->
	<view class="">
		<view class="content">
			<view class="describe">
				<text>车牌号</text>
				<u-input v-model="carinfo.carNum" type="text" :clearable="false" placeholder='请输入车牌号'
					placeholder-style="font-size:'28rpx';text-align:right" :custom-style="inputSty" />
			</view>
			<view class="describe">
				<text>车主</text>
				<u-input v-model="carinfo.carName" type="text" :clearable="false" placeholder='请输入车主姓名'
					placeholder-style="font-size:'28rpx';text-align:right" :custom-style="nameSty" />
			</view>
			<view class="phoneNumber describe">
				<text>联系电话</text>
				<u-input v-model="carinfo.carTel" type="text" :clearable="false" placeholder='请输入正确的手机号码'
					placeholder-style="font-size:'28rpx'" :custom-style="numSty" />
			</view>
			<view class="upImg">
				<text>车辆照片</text>
				<text class="format">只支持jpg. png格式</text>
				<u-upload  :file-list="fileList" upload-text="上传照片"> </u-upload>
			</view>

			<u-button :custom-style="customStyle" @click="save">保存</u-button>
		</view>
		<u-popup v-model="show" mode="bottom" border-radius="24" :closeable="true">
			<view class="popup">
				<view class="title">确认车辆信息</view>
				<view class="sure">
					<view class="sureInfo">
						<view >
							车牌
						</view>
						<text>京5789A</text>
					</view>
					<view class="sureInfo">
						<view >
							车主
						</view>
						<text>小小</text>
					</view>
					<view class="sureInfo">
						<view >
							手机号码
						</view>
						<text>1328678945</text>
					</view>
				</view>
				<u-button :custom-style="Style" @click="sure()">确认</u-button>
			</view>
		</u-popup>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				carinfo:{
					carNum: '',
					carName: '',
					carTel:''
				},
				inputSty: {
					textAlign:'right'
				},
				nameSty: {
					textAlign:'right'
				},
				numSty: {
					textAlign:'right'
				},
				customStyle: {
					fontSize: '32rpx',
					borderRadius: '16rpx',
					background: '#1677FE',
					height: '100rpx',
					margin: '100rpx 55rpx 0rpx',
					color: "#fff"
				},
				fileList: [{
					url: '',
				}],
				show: false,
				Style: {
					fontSize: '32rpx',
					borderRadius: '16rpx',
					background: '#1677FE',
					height: '100rpx',
					margin: '100rpx 55rpx 0rpx',
					color: "#fff"
				}
			}
		},
		methods: {
			save(){
				this.show=true
			},
			sure(){
				this.show=false
				// 获取openId
				let openId = uni.getStorageSync("userInfo").openid;
				let payload = {
					...this.carinfo,
					openid: openId,
					version:1,
					image:''
				};
				this.$Api.doEditCarInfo(payload).then((res) => {
					if(res.data.code==200){
						this.$u.toast('保存成功');
						uni.navigateBack()
					}
				});
			}
		}
	}
</script>

<style scoped lang="scss">
	@import "addCar.scss"
</style>